package main

import "fmt"

func binaryFind(intsilce []int, leftIndex, rightIndex, findVal int){
	//二分查找的退出条件
	if leftIndex > rightIndex {
		fmt.Println("没有找到！")
	}
	// 取中间值
	middelIndex := (leftIndex + rightIndex)/2
	// 根据大小走修改左右边界
	if intsilce[middelIndex] < findVal {
		binaryFind(intsilce, middelIndex+1, rightIndex, findVal)
	} else if intsilce[middelIndex] > findVal {
		binaryFind(intsilce, leftIndex, middelIndex-1, findVal)
	} else {
		fmt.Println("找到了，index值为:", middelIndex)
	}
}

func main () {
	intslice := []int{15, 18, 65, 75, 88}
	binaryFind(intslice, 0, 4, 75)
}